/**
 * Description:
 * Class Name:BlockingQueueTest
 * Date:2022/5/8 14:59
 *
 * @author LTisme
 * @version JAVA17
 */
package 疯狂Java讲义.第16章_多线程._16_6_线程间通信._16_6_3_使用阻塞队列BlockingQueue来控制线程通信;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;

public class BlockingQueueTest {
    public static void main(String[] args) throws InterruptedException {
        // 定义一个长度为2的阻塞队列
        BlockingQueue<String> blockingQueue = new ArrayBlockingQueue<>(2);
        blockingQueue.put("Java");
        blockingQueue.put("Java");
        blockingQueue.put("Java");      // 会阻塞线程
    }
}
